﻿using DearlerPlatform.Common;
using DearlerPlatform.Core.DataBaseCommon;
using DearlerPlatform.Service.ProductApp;
using DearlerPlatform.Service.ProductApp.Views;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DearlerPlatform.WebApi.Controllers
{
    /// <summary>
    /// 商品管理接口
    /// </summary>
    [Authorize]
    [Route("api/[controller]")]
    //[Authorize(Roles = "User")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly IProduceService _produce;

        public ProductController(IProduceService produce)
        {
            this._produce = produce;
        }
        /// <summary>
        /// 查询商品分页数据
        /// </summary>
        /// <param name="query">查询参数对象</param>
        /// <returns>商品数据列表</returns>
        [HttpPost]
        [Route("[action]")]
        public async Task<ActionResult<ApiResult<PageViewBase<List<ProductsVM>>>>> GetProductPageListAsync(QueryParameterBase query)
        {
            var res = await _produce.GetPageListAsync(query);
            return Ok(res);
        }
    }
}
